<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">

          <a-col :md="6" :sm="8">
            <a-form-item label="订单编号">
              <a-input placeholder="请输入订单名称" v-model="queryParam.id"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="抢单分类">
              <a-select placeholder="抢单分类" v-model="queryParam.grabType">
                <a-select-option v-for="item in grabTypes" :key="item.key" :value="item.key">{{ item.val }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="订单状态">
              <a-select placeholder="请选择订单状态" v-model="queryParam.orderStatus">
                <a-select-option v-for="item in orderStatusSetect" :key="item.key" :value="item.key">{{ item.val }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="接单人">
                <a-input placeholder="请输入接单人" v-model="queryParam.takeOrders"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="要求">
                <a-input placeholder="请输入要求" v-model="queryParam.demand"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="技术要求">
                <a-input placeholder="请输入技术要求" v-model="queryParam.technical"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="费用">
                <a-input placeholder="请输入费用" v-model="queryParam.cost"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
<!--    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">发布订单</a-button>
    </div>-->

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
           <a href="javascript:;" @click="handleAppointList(record)">指派订单</a>
           <a-divider  type="vertical" />
           <a href="javascript:;" @click="handleDetail(record)">详情</a>
        </span>
        <span slot="cost" slot-scope="text">
          {{text}}元
        </span>
        <span slot="fieldText" slot-scope="text">
          <div style="width: 200px"  class="contText" :title="text">{{ text }}</div>
        </span>
        <span slot="orderStatus" slot-scope="text,record">
            <a-tag  :color="getColor(record)" style="width: 100%;color: rgba(0, 0, 0, 0.65);height: 38px;font-size: 14px;line-height: 2.5;" >{{text}}</a-tag>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <orderForm-modal ref="modalForm" @ok="modalFormOk"></orderForm-modal>
    <OrderRaiseList ref="modalList"  @ok="modalFormOk"> </OrderRaiseList>
  </a-card>
</template>

<script>
import OrderFormModal from './modules/OrderFormModal'
import OrderRaiseList from '../orderRaise/OrderRaiseList'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import {Dict}   from '@/api/Dict'
import {getAction} from "@api/manage";
import {mapGetters} from "vuex";
export default {
  name: "OrderFormList",
  mixins:[JeecgListMixin,Dict],
  components: {
    OrderFormModal,
    OrderRaiseList
  },
  data () {
    return {
      description: '订单管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:30,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title: '创建时间',
          align:"center",
          dataIndex: 'createTime',
          width: 160
        },
        {
          title: '订单号',
          align:"center",
          dataIndex: 'orderNumber',
        },
        {
          title: '抢单分类',
          align:"center",
          dataIndex: 'grabType_dictText',
        },
        {
          title: '要求',
          align:"center",
          dataIndex: 'demand',
          width: 200,
          ellipsis: true,
          scopedSlots: { customRender: 'fieldText' },
        },
        {
          title: '费用',
          align:"center",
          dataIndex: 'cost',
          scopedSlots: { customRender: 'cost' },
          width: 80
        },
        {
          title: '要求完成时间',
          align:"center",
          dataIndex: 'finishTime',
        },
        {
          title: '指派人',
          align:"center",
          dataIndex: 'createByName',
        },
        {
          title: '接单人',
          align:"center",
          dataIndex: 'takeOrders',
          width: 80
        },
        {
          title: '订单状态',
          align:"center",
          dataIndex: 'orderStatus_dictText',
          scopedSlots: { customRender: 'orderStatus' },
          width: 150
        },
        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          scopedSlots: { customRender: 'action' },
          width: 180,
        }
      ],
      url: {
        list: "/orderForm/orderForm/listByAppoint",
      },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    ...mapGetters(["userInfo"]),
    loadData(arg) {
      if(!this.url.list){
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      params.orderStatus=6;
      if(this.userInfo().rolestr=='admin'){
      }else {
        params.createBy=this.userInfo().username;
      }
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total;
        }
      })
    },
    handleAppointList:function(record){
      this.$refs.modalList.showlist(record);
    },
  }
}
</script>
<style lang="less" scoped>
/** Button按钮间距 */
.ant-btn {
  margin-left: 3px
}
.ant-card-body .table-operator{
  margin-bottom: 18px;
}
.ant-table-tbody .ant-table-row td{
  padding-top:15px;
  padding-bottom:15px;
}
.anty-row-operator button{margin: 0 5px}
.ant-btn-danger{background-color: #ffffff}

.ant-modal-cust-warp{height: 100%}
.ant-modal-cust-warp .ant-modal-body{height:calc(100% - 110px) !important;overflow-y: auto}
.ant-modal-cust-warp .ant-modal-content{height:90% !important;overflow-y: hidden}
.contText{
  overflow: hidden;/*内容超出后隐藏*/
  text-overflow: ellipsis;/* 超出内容显示为省略号*/
  white-space: nowrap;/*文本不进行换行*/
}
</style>